package app.caretrack.teststruts;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

public class TestJackson {
    public static void main(String[] args) {
        Customer c1 = new Customer();
        c1.setId(1);
        c1.setName("Fucheng");
        c1.setBirthDay(new Date());
        Customer c2 = new Customer();
        c2.setId(2);
        c2.setName("Jacky");
        List cList = new ArrayList();
        cList.add(c1);
        cList.add(c2);
        ObjectMapper mapper = new ObjectMapper();
        try {
            mapper.writeValue(System.out, cList);
        } catch (JsonGenerationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JsonMappingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

class Customer {
    private int id;
    private String name;
    private Date birthDay;

    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getBirthDay() {
        return this.birthDay;
    }

    public void setBirthDay(Date birthDay) {
        this.birthDay = birthDay;
    }
}
